import { segment } from "oicq";
import fetch from "node-fetch";
import fs from "fs";
import common from'../../lib/common/common.js'
import { url } from "inspector";
let res1
let a 
let res1_url
let res1_qs
let url1
let qq
let res2_sk
let res2_psk
let res2_name
let res2_uin
export class example extends plugin {
    constructor() {
      super({
        /** 功能名称 */
        name: 'skey',
        /** 功能描述 */
        dsc: 'skey',
        /** https://oicqjs.github.io/oicq/#events */
        event: 'message',
        /** 优先级，数字越小等级越高 */
        priority: 1,
        rule: [
          {
            /** 命令正则匹配 */
            reg: '#特别关心$',
            /** 执行方法 */
            fnc: 'tbgx'
          },
          {
            /** 命令正则匹配 */
            reg: '#查看',
            /** 执行方法 */
            fnc: 'tbgx1'
          },
          
        ]
      })
    }  async tbgx(e) {qq=e.user_id
        url1 = 'http://ovooa.com/API/Skey/api.php?type=qzone.qq.com'
        res1 = await fetch(url1)
        res1 = await res1.json()
        
        res1_url = res1.data
        res1_url = res1_url.url
    
        res1_qs =  res1.data
        res1_qs = res1_qs.qrsig
       await e.reply(segment.image(res1_url))
        await e.reply('请用QQ扫码扫描此二维码，扫完后请回复：#查看,注意，一个二维码仅供一个人使用，请耐心等待。二维码容易失效，请尽快使用。')
        
        
        a = 1



    }
    async tbgx1(e) {
if(a!==1){return false}else{
    let url2 = `http://ovooa.com/API/Skey/api.php?type=qzone.qq.com&qrsig=${res1_qs}`
    let res2 = await fetch(url2)
    res2 = await res2.json()
    res2_sk=  res2.data.skey
    res2_psk=  res2.data.p_skey
    res2_name =  res2.name
    res2_uin =  res2.uin
 let uuurrrlll= `http://q.dsbs.fun/api/tbgx?uin=${qq}&skey=${res2_sk}&pskey=${res2_psk}`
 let res3 = await fetch(uuurrrlll)
 res3= await res3.text()
 e.reply(res3)
    a=0
    res1_url = ''
res1_qs = ''
 url1 = ''
 qq  = ''
res2_sk = ''
res2_psk = ''
res2_name = ''
res2_uin = ''
}



    }
}